<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        const url = `ws://localhost:7834/api/tank/ws?mode=final`
        function createWs(wsurl){
            const ws = new WebSocket(wsurl)
            ws.onmessage = function (data){
                console.log(data)
            }
            ws.onclose = function (){
                console.log("连接关闭")
                setTimeout(()=>{
                    createWs(wsurl)
                }, 3000)
            }
            ws.onerror = function (err){
                console.log("发生错误",err)
            }
        }
        createWs(url)
    </script>
</body>
</html>